﻿using System;
using System.Collections.Generic;

using FireBus.Contracts;


namespace FireBus.Core
{
	public class Storage : MarshalByRefObject, IStorage
	{
		private readonly Host _Host;


		internal Storage(Host host)
		{
			_Host = host;
		}


		public ExtensionToken[] GetExtensions()
		{
			return
				new List<ExtensionToken>(
					_Host.GetExtensions()).ToArray();
		}

		public void AddExtension(ExtensionToken token)
		{
			_Host.AddExtension(token);
		}

		public void RemoveExtension(ExtensionName name)
		{
			_Host.RemoveExtension(name);
		}

		public void LoadExtension(ExtensionName name)
		{
			_Host.BeginLoadExtension(name, null, null);
		}

		public void UnloadExtension(ExtensionName name)
		{
			_Host.BeginUnloadExtension(name, null, null);
		}

		public ExtensionState GetExtensionState(ExtensionName name)
		{
			return _Host.GetExtensionState(name);
		}

		public override Object InitializeLifetimeService()
		{
			return null;
		}
	}
}
